F!! Printable scenario - to better support BDD#460
Open
emilybache wants to merge 9 commits intomasterfrom
Open
F!! Printable scenario - to better support BDD#460emilybache wants to merge 9 commits intomasterfrom
emilybache wants to merge 9 commits intomasterfrom
Conversation
LarsEckart
reviewed
Jan 11, 2024
| ## Sample Code | ||
|
|
||
| I need some help with this part of the documentation. I'd like to include PrintableScenarioTest here as an example. | ||
| <!-- snippet: bdd_test --> |
Contributor
There was a problem hiding this comment.
I think what you need is the following. These comments in the java file:
// begin-snippet: MySnippetName
public class PrintableScenarioTest
{
@Test
public void printBDDScenario() throws Exception
{
PrintableScenario story = new PrintableScenario("Buy Groceries", "Bob puts two items in the shopping cart");
User currentUser = new User();
ShoppingCart shoppingCart = new ShoppingCart(currentUser);
story.given(new Printable<>(currentUser, UserPrinter::print),
new Printable<>(shoppingCart, ShoppingCartPrinter::print));
story.when("Add oranges to the cart", () -> {
shoppingCart.add("Oranges", 1, BigDecimal.valueOf(5));
return null;
});
story.when("Add apples to the cart", () -> {
shoppingCart.add("Apples", 3, BigDecimal.valueOf(4));
return null;
});
Approvals.verify(story.then());
}
}
// end-snippetand then you can reference it here in markdown with snippet: MySnippetName
Contributor
Author
|
I just updated this PR following conversation with Llewellyn. I think he probably wants to change a few more things too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've added a new library class PrintableScenario, with an example test of how to use it, and made a start on the documentation.
One of the methods has a checked exception which seemed to affect another test - I'm not sure what to do about that.
Look forward to discussing this proposed change with Llewellyn - we have booked a meeting to do so soon.